#include <stdio.h>
#include <stdlib.h>
#include "gestion.h"
 void ajout_malade(malade *m){
	FILE* f=fopen("n.txt","r+");
 	FILE* fout =fopen ("malade.txt","a");
	fscanf(f,"%d",&n);
 	if(n== 100){
		fout=fopen ("file.txt","a");
	saisie (m);
	fprintf(f,"%s ",m->nom);
	fprintf(f,"%s ",m->prenom);
	fprintf(f,"%ld ",m->cin);
	fprintf(f,"%d ",m->age);
	fprintf(f,"%ld ",m->id);
	fprintf(f,"%s ",m->type_sang);
	fprintf(f,"%d ",m->lit occupe);
	fprintf(f,"%s ",m->situation_civile);
	fprintf(f,"%s",m->sexe);
	fprintf(f,"%s\n",m->date_d'arrive);
	fclose(f);}
	else { f= fopen("n.txt","w+");
		n++;
		rewind (f);
		fprintf(f,"%d",n);
		fclose(f);
	}
	saisie (p);
	fprintf(fout,"%s ",m->nom);
	fprintf(fout,"%s ",m->prenom);
	fprintf(fout,"%ld ",m->cin);
	fprintf(fout,"%d ",m->age);
	fprintf(fout,"%ld ",m->id);
	fprintf(fout,"%s ",m->type_sang);
	fprintf(fout,"%d ",m->lit occupe);
	fprintf(fout,"%s ",m->situation_civile);
	fprintf(fout,"%s",m->sexe);
	fprintf(fout,"%s\n",m->date_d'arrive);
	fclose(fout);


}

#include <stdlib.h>
#include <stdio.h>
#include "gestion.h"

void suppression(malade *m,FILE* fin){
	FILE* ft=fopen("mal_temp.txt","a");
	char nom[20],prenom[20],nat[20],pre[20];
	int etat;
	long id;
	while(fscanf(fin,"%s %s %d %ld %s %s\n",nom,prenom,&age,&id,natEOF){
		if(id=!p->id){ 
		fprintf(ft,"%s ",nom);
		fprintf(ft,"%s ",prenom);
		fprintf(ft,"%ld ",id);
		fprintf(ft,"%ld ",cin);		
		fprintf(ft,"%s ",nat);
		fprintf(ft,"%s ",situation_civile);
		fprintf(ft,"%s ",sexe);
		fprintf(ft,"%d",age);
		fprintf(ft,"\n");
	}}
	rcemove("malade.txt");
	rename("mal_temp.txt","malade.txt");
}

void supp_malade(malade *m){
	FILE* fin= fopen ("malade.txt","r");
	FILE* f= fopen ("n.txt","r+");
	suppression1(m,fin);
	fclose(fin);
	fin= fopen ("malade.txt","a");
 	fscanf(f,"%d",&n);
	if(n<100){
		rewind(f);
		fprintf(f,"%d",n-1);
	}else {
		FILE * fi = fopen("file.txt","r");
		if(fgets (==0) {
			rewind(f);
			fprintf(f,"%d",n-1);
			return ;
		}
		malade m_t;
		fscanf(fi,"%s %s %d %ld %s %s\n",m_t->nom,m_t->prenom,&m_t->etat,&m_t->id,m_t->nat,m-t>pre);
c		suppression(fi,m_t);
		ajout1(m_t);
	}
}
